<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <a href="/home">Home</a>
  <a href="/about">About</a>
  <script>
    //获取两个链接元素
    let links = document.querySelectorAll('a');
    //遍历l
    links.forEach(link => {
      //绑定事件
      link.onclick = function(e){
        //阻止默认行为
        e.preventDefault();
        //页面进行无刷新跳转
        history.pushState({id: 20}, '', link.href);
      }
    });

  </script>
</body>
</html>